/**
 *
 */
package com.angel.annotation.finders;

import java.lang.annotation.Annotation;

import com.angel.annotation.interfaces.AnnotationObjectFinder;

/**
 *
 * @author William
 *
 */
public class AnnotationClassFinder implements AnnotationObjectFinder{

	private static AnnotationObjectFinder instance;

	private AnnotationClassFinder(){
		super();
	}

	public static synchronized AnnotationObjectFinder getInstance(){
		if(instance == null){
			instance = new AnnotationClassFinder();
		}
		return instance;
	}

	public <T extends Annotation> Annotation findAnnotationAt(Object object, Class<T> annotationClass) {
		return object.getClass().getAnnotation(annotationClass);
	}

	public <T extends Annotation> Object findTargetObjectFor(Object object, Class<T> annotationClass) {
		return (this.findAnnotationAt(object, annotationClass) != null) ? object.getClass(): null;
	}

}
